﻿@model Transport.Areas.Administrator.Models.UserModel
  
@using (Html.BeginForm("save", "user", FormMethod.Post))
{
    <div class="section-header">
        <div class="title">
            <img src="@Url.Content("~/Areas/Administrator/Content/images/ico-catalog.png")" alt="" />
            @(Model.UserId > 0 ? "Sửa nhân viên" : "Tạo mới nhân viên")
        </div>
        <div class="options">
            <button type="submit" name="save" value="save" class="t-button">Lưu</button>
            <a href="@Url.Action("index")" class="t-button">Quay lại</a>
        </div>
    </div>
    
    @Html.ValidationSummary(true)
    @Html.HiddenFor(model => model.UserId)
    <table width="100%">
        <tr>
            <td class="adminTitle">
                @Html.Label("Họ")
                <span class="field_required">*</span>
            </td>
            <td class="adminData">
                @Html.TextBoxFor(model => model.FirstName)
                @Html.ValidationMessageFor(model => model.FirstName, "Họ là bắt buộc nhập.")
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.Label("Tên")
                <span class="field_required">*</span>
            </td>
            <td class="adminData">
                @Html.TextBoxFor(model => model.LastName)
                @Html.ValidationMessageFor(model => model.LastName, "Tên là bắt buộc nhập.")
            </td>
        </tr>  
        <tr>
            <td class="adminTitle">
                @Html.Label("Email")
                <span class="field_required">*</span>
            </td>
            <td class="adminData">
                @Html.TextBoxFor(model => model.Email)
                @Html.ValidationMessageFor(model => model.Email)
            </td>
            <td></td>
        </tr>
        @if (Model.UserId > 0)
        {
            @Html.HiddenFor(model => model.Password)
            @Html.HiddenFor(model => model.ConfirmPassword)
            <tr>
                <td class="adminTitle">
                    @Html.Label("Mật khẩu")
                </td>
                <td class="adminData" style="padding-bottom:10px;padding-top:10px;">
                    <a href="@Url.Action("ChangePassword", "User", new { id = Model.UserId})">Thay đổi mật khẩu</a>
                </td>
            </tr> 
        }
        else
        {
        <tr>
            <td class="adminTitle">
                 @Html.Label("Mật khẩu")
                <span class="field_required">*</span>
            </td>
            <td class="adminData">
       
                 @Html.PasswordFor(model => model.Password)
                @Html.ValidationMessageFor(model => model.Password)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                 @Html.Label("Xác nhận mật khẩu")
                <span class="field_required">*</span>
            </td>
            <td class="adminData">
                @Html.PasswordFor(model => model.ConfirmPassword)
                @Html.ValidationMessageFor(model => model.ConfirmPassword)
            </td>
        </tr>
        }
        <tr>
            <td class="adminTitle">
                @Html.Label("Quyền")
                <span class="field_required">*</span>
            </td>
            <td class="adminData">
                @Html.DropDownListFor(model => model.RoleId, new SelectList(Model.AvailableUserRoles, "RoleId", "RoleName"), "-Chọn-")
                @Html.ValidationMessageFor(model => model.RoleId, "Quyền là bắt buộc chọn.")
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.Label("Trung tâm")
                <span class="field_required">*</span>
            </td>
            <td class="adminData">
                @Html.DropDownListFor(model => model.MyOfficeId, new SelectList(Model.AvailableOffices, "MyOfficeId", "OfficeName"), "-Chọn-")
                @Html.ValidationMessageFor(model => model.MyOfficeId, "Trung tâm là bắt buộc chọn.")
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.Label("Địa chỉ")
            </td>
            <td class="adminData">
                @Html.TextBoxFor(model => model.Address)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.Label("Kích hoạt")
            </td>
            <td align="left">
                @Html.CheckBoxFor(model => model.IsLockedOut)
            </td>
        </tr>     
    </table>
}


